using System;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    /**
     * Classname : Nguoidung
     * Version information :1.0
     * Date  :26-09-2006
     * Copyright notice : 
     */

    public class DALog : DbObject
    {
        protected SqlConnection connec;

        public DALog(SqlConnection Connection)
        {
            connec = Connection;
        }
        
		// add a new question
		// Them ban ghi hien hanh
        public void insertLog(int Level_ID, int HocVien_ID, int Action, int User_ID)
		{
            int numAffected;
			// create the parameters
            SqlParameter[] parameters =  {	    new SqlParameter("@Level_ID", SqlDbType.Int),
                                                new SqlParameter("@HocVien_ID", SqlDbType.BigInt),
                                                new SqlParameter("@Action", SqlDbType.Int),
                                                new SqlParameter("@RunningTime", SqlDbType.DateTime),
                                                new SqlParameter("@User_ID", SqlDbType.BigInt)
										 };	
			// set the values
            parameters[0].Value = Level_ID;
            parameters[1].Value = HocVien_ID;
            parameters[2].Value = Action;
            parameters[3].Value = DateTime.Now;
            parameters[4].Value = User_ID;
		
			// run the procedure
            RunProcedure("sp_Log_insertLog", parameters, out numAffected, connec);
		}

        public void insertLogWithLink(int Level_ID, int HocVien_ID, int Action, int User_ID, string ip_str_malink)
        {
            int numAffected;
            // create the parameters
            SqlParameter[] parameters =  {	    new SqlParameter("@Level_ID", SqlDbType.Int),
                                                new SqlParameter("@HocVien_ID", SqlDbType.BigInt),
                                                new SqlParameter("@Action", SqlDbType.Int),
                                                new SqlParameter("@RunningTime", SqlDbType.DateTime),
                                                new SqlParameter("@User_ID", SqlDbType.BigInt),
                                                new SqlParameter("@MaLink", SqlDbType.VarChar, 50)
										 };
            // set the values
            parameters[0].Value = Level_ID;
            parameters[1].Value = HocVien_ID;
            parameters[2].Value = Action;
            parameters[3].Value = DateTime.Now;
            parameters[4].Value = User_ID;
            parameters[5].Value = ip_str_malink;

            // run the procedure
            RunProcedure("sp_Log_insertLogWithLink", parameters, out numAffected, connec);
        }
    }
}